package io.github.service.impl;


import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import io.github.dao.SimSeqGroupDao;
import io.github.entity.SimSeqGroupEntity;
import io.github.service.SimSeqGroupService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author Max
 * <br>
 * date 2020/2/24 10:00
 */

@Service
public class SimSeqGroupServiceImpl extends ServiceImpl<SimSeqGroupDao, SimSeqGroupEntity> implements SimSeqGroupService {


    @Override
    public void save(SimSeqGroupEntity entity) {
        baseMapper.insert(entity);
    }

    @Override
    public void delete(Integer id) {
        baseMapper.deleteById(id);
    }

    @Override
    public void update(SimSeqGroupEntity entity) {
        Wrapper wrapper = new EntityWrapper();
        wrapper.eq("id",entity.getId());
        this.update(entity,wrapper);
    }

    @Override
    public Page<SimSeqGroupEntity> list(Integer offset, Integer limit, String name) {
        Wrapper<SimSeqGroupEntity> wrapper = new EntityWrapper<>();
        if(StringUtils.isNotBlank(name)) {
            wrapper.like("group_no",name);
        }

        Page<SimSeqGroupEntity> page = new Page<>(offset,limit);
        return this.selectPage(page,wrapper);
    }
}